name: K8s on LVH
description: Creates K8s cluster inside LVH VM, and then exposes K8s cluster to GHA runner.

inputs:
  kernel:
    required: true
    type: string
  kind-params:
    required: true
    type: string
  kind-image-vsn:
    type: string
  test-name:
    required: true
    type: string

runs:
  using: composite
  steps:
    - name: Provision LVH VMs
      uses: cilium/little-vm-helper@9d758b756305e83718a51b792a5aeabd022a39ec # v0.0.16
      with:
        test-name: ${{ inputs.test-name }}
        image-version: ${{ inputs.kernel }}
        host-mount: ./
        cpu: 4
        mem: 12G
        install-dependencies: 'true'
        port-forward: '6443:6443'
        cmd: |
          git config --global --add safe.directory /host

    - name: Create K8s cluster
      uses: cilium/little-vm-helper@9d758b756305e83718a51b792a5aeabd022a39ec # v0.0.16
      with:
        provision: 'false'
        cmd: |
          cd /host
          if [ "${{ inputs.kind-image-vsn }}" != "" ]; then
            export IMAGE=kindest/node:${{ inputs.kind-image-vsn }}
          fi
          ./contrib/scripts/kind.sh ${{ inputs.kind-params }} 0.0.0.0 6443

    - name: Copy kubeconfig
      shell: bash
      run: |
        mkdir ~/.kube
        scp -o StrictHostKeyChecking=no -P 2222 root@localhost:/root/.kube/config ~/.kube/config
